package wechat.service.base;

import wechat.resources.InstanceResource;

public class WechatApi {
	//access_token
	private static String api_access_token = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=CORPID&corpsecret=SECRET";
	//JSticket
	private static String api_jsticket = "https://qyapi.weixin.qq.com/cgi-bin/get_jsapi_ticket?access_token=ACCESS_TOKEN";
	//授权code
	private static String api_user_token = "https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?access_token=ACCESS_TOKEN&code=CODE";
	//userid转换成openid
	private static String api_convert_to_openid = "https://qyapi.weixin.qq.com/cgi-bin/user/convert_to_openid?access_token=ACCESS_TOKEN";
	//openid转换成userid
	private static String api_convert_to_userid = "https://qyapi.weixin.qq.com/cgi-bin/user/convert_to_userid?access_token=ACCESS_TOKEN";
	//消息发送
	private static String api_send_message = "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=ACCESS_TOKEN";
	
	//创建成员
	private static String api_create_user = "https://qyapi.weixin.qq.com/cgi-bin/user/create?access_token=ACCESS_TOKEN";
	//更新成员
	private static String api_update_user = "https://qyapi.weixin.qq.com/cgi-bin/user/update?access_token=ACCESS_TOKEN";
	//删除成员
	private static String api_delete_user = "https://qyapi.weixin.qq.com/cgi-bin/user/delete?access_token=ACCESS_TOKEN&userid=USERID";
	//批量删除成员
	private static String api_batchdelete_user = "https://qyapi.weixin.qq.com/cgi-bin/user/batchdelete?access_token=ACCESS_TOKEN";
	//获取成员
	private static String api_get_user = "https://qyapi.weixin.qq.com/cgi-bin/user/get?access_token=ACCESS_TOKEN&userid=USERID";
	//获取部门成员
	private static String api_simplelist_user = "https://qyapi.weixin.qq.com/cgi-bin/user/simplelist?access_token=ACCESS_TOKEN&department_id=DEPARTMENT_ID&fetch_child=FETCH_CHILD&status=STATUS";
	//获取部门成员(详情)
	private static String api_list_user = "https://qyapi.weixin.qq.com/cgi-bin/user/list?access_token=ACCESS_TOKEN&department_id=DEPARTMENT_ID&fetch_child=FETCH_CHILD&status=STATUS";
	
	//获取部门列表
	private static String api_list_department = "https://qyapi.weixin.qq.com/cgi-bin/department/list?access_token=ACCESS_TOKEN&id=ID";
	
	
	
	
	
	
	public static String getApi_access_token(InstanceResource instanceResource) {
		return api_access_token.replace("CORPID", instanceResource.getCorpid()).replace("SECRET",instanceResource.getSecret());
	}
	
	public static String getJsticket(String access_token) {
		return api_jsticket.replace("ACCESS_TOKEN", access_token);
	}
	
	public static String getUser_token(String access_token,String code) {
		return api_user_token.replace("ACCESS_TOKEN", access_token).replace("CODE", code);
	}
	
	public static String getConvert_to_openid (String access_token) {
		return api_convert_to_openid.replace("ACCESS_TOKEN", access_token);
	}
	
	public static String getConvert_to_userid (String access_token) {
		return api_convert_to_userid.replace("ACCESS_TOKEN", access_token);
	}
	
	public static String getSend_message(String access_token) {
		return api_send_message.replace("ACCESS_TOKEN", access_token);
	}
	
	public static String getCreate_user(String access_token) {
		return api_create_user.replace("ACCESS_TOKEN", access_token);
	}
	
	public static String getUpdate_user(String access_token) {
		return api_update_user.replace("ACCESS_TOKEN", access_token);
	}
	
	public static String getDelete_user(String access_token,String userid) {
		return api_delete_user.replace("ACCESS_TOKEN", access_token).replace("USERID", userid);
	}
	
	public static String getBatchdelete_user(String access_token) {
		return api_batchdelete_user.replace("ACCESS_TOKEN", access_token);
	}
	
	public static String getGet_user(String access_token,String userid) {
		return api_get_user.replace("ACCESS_TOKEN", access_token).replace("USERID", userid);
	}
	
	public static String getSimplelist_user(String access_token,String department_id,String fetch_child, String status) {
		return api_simplelist_user.replace("ACCESS_TOKEN", access_token).replace("DEPARTMENT_ID", department_id).replace("FETCH_CHILD", fetch_child).replace("STATUS", status);
	}
	
	public static String getList_user(String access_token,String department_id,String fetch_child, String status) {
		return api_list_user.replace("ACCESS_TOKEN", access_token).replace("DEPARTMENT_ID", department_id).replace("FETCH_CHILD", fetch_child).replace("STATUS", status);
	}
	
	
	public static String getList_department(String access_token,String department_id) {
		return api_list_department.replace("ACCESS_TOKEN", access_token).replace("ID", department_id);
	}
}
